﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
  <Style x:Key="ToolbarDropDownButtonStyle" TargetType="{x:Type Fluent:DropDownButton}">
    <Setter Property="Template" Value="{DynamicResource ToolbarDropDownButtonControlTemplate}" />
    <Setter Property="Height" Value="22" />
    <Setter Property="Width" Value="13" />
    <Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
    <Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
    <Setter Property="Foreground" Value="{DynamicResource DefaultFontBrush}" />
    <Setter Property="FocusVisualStyle" Value="{DynamicResource ControlStyleEmptyFocus}" />
  </Style>
  <ControlTemplate x:Key="ToolbarDropDownButtonControlTemplate" TargetType="{x:Type Fluent:DropDownButton}">
    <Grid>
      <Border x:Name="PART_ButtonBorder" BorderThickness="1" CornerRadius="2"
              Background="{DynamicResource TransparentBrush}" BorderBrush="{DynamicResource TransparentBrush}" Height="22"
              HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="13">
        <Border x:Name="border1" Height="Auto" BorderBrush="{DynamicResource TransparentBrush}" BorderThickness="1"
                CornerRadius="2" Background="{DynamicResource TransparentBrush}">
          <Grid x:Name="grid" Margin="0" Background="#00000000">
            <Rectangle x:Name="rectangle" StrokeThickness="0" Visibility="Collapsed" Margin="0">
              <Rectangle.Fill>
                <RadialGradientBrush Center="0.503,1" GradientOrigin="0.503,1" RadiusY="0.202">
                  <GradientStop Color="#7FFFFFFF" Offset="0" />
                  <GradientStop Offset="1" />
                </RadialGradientBrush>
              </Rectangle.Fill>
            </Rectangle>
            <StackPanel x:Name="stackPanel" Width="Auto" Orientation="Horizontal" VerticalAlignment="Top"
                        Margin="-1,4,0,0" Background="#00000000">
              <Image x:Name="iconImage" HorizontalAlignment="Left" Height="8" Stretch="None" VerticalAlignment="Top"
                     Source="{TemplateBinding LargeIcon}" Width="8" Margin="-3,0,2,0" />
            </StackPanel>
          </Grid>
        </Border>
      </Border>
      <Popup x:Name="PART_Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True"
             Focusable="False" PopupAnimation="Fade" Margin="0,0,-4,0" VerticalAlignment="Top" Grid.ColumnSpan="2">
        <Grid Name="DropDown" SnapsToDevicePixels="True" Margin="0" VerticalAlignment="Top">
          <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="10" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="10" />
          </Grid.ColumnDefinitions>
          <Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="4" Height="4" Grid.Row="1"
                     Grid.Column="1" StrokeThickness="0" Margin="-1,-1,0,0">
            <Rectangle.Fill>
              <RadialGradientBrush RadiusX="0.984" Center="0.017,0.002" GradientOrigin="0.017,0.002" RadiusY="1">
                <GradientStop Color="#3F000000" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="-1,3,0,0" VerticalAlignment="Top" Width="4"
                     Height="4" Grid.Column="1" Grid.Row="0">
            <Rectangle.Fill>
              <RadialGradientBrush Center="0.032,1.01" GradientOrigin="0.032,1.01" RadiusX="0.984" RadiusY="1">
                <GradientStop Color="#3F000000" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="3,-1,0,0" VerticalAlignment="Top" Width="4"
                     Height="4" Grid.Column="0" Grid.Row="1">
            <Rectangle.Fill>
              <RadialGradientBrush Center="0.996,0.027" GradientOrigin="0.996,0.027" RadiusX="0.984" RadiusY="1">
                <GradientStop Color="#3F000000" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </RadialGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <Rectangle StrokeThickness="0" HorizontalAlignment="Stretch" Margin="7,-1,1,0" VerticalAlignment="Top"
                     Width="Auto" Height="4" Grid.Column="0" Grid.Row="1">
            <Rectangle.Fill>
              <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" MappingMode="RelativeToBoundingBox">
                <GradientStop Color="#3F000000" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </LinearGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <Rectangle StrokeThickness="0" HorizontalAlignment="Left" Margin="-1,7,0,1" VerticalAlignment="Stretch"
                     Width="4" Height="Auto" Grid.Column="1" Grid.Row="0">
            <Rectangle.Fill>
              <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5" MappingMode="RelativeToBoundingBox">
                <GradientStop Color="#3F000000" Offset="0" />
                <GradientStop Color="#00000000" Offset="1" />
              </LinearGradientBrush>
            </Rectangle.Fill>
          </Rectangle>
          <Border x:Name="PART_DropDownBorder" MinWidth="{TemplateBinding ActualWidth}" SnapsToDevicePixels="True"
                  Background="{DynamicResource ContextMenuBarBackgroundBrush}" BorderBrush="{DynamicResource ContextMenuBarBorderBrush}"
                  BorderThickness="1" CornerRadius="1" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <Grid Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Top">
              <Border VerticalAlignment="Top" Width="Auto" Height="Auto"
                      BorderBrush="{DynamicResource ContextMenuBarBackgroundBrush}" BorderThickness="1" CornerRadius="1" />
              <Grid Margin="1" HorizontalAlignment="Stretch" VerticalAlignment="Top">
                <Grid.RowDefinitions>
                  <RowDefinition Height="*" />
                  <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Rectangle Fill="{x:Null}" Stretch="Fill" Stroke="#FFE2E4E7" HorizontalAlignment="Left"
                           Margin="24,0,0,0" Width="1" Height="Auto" Grid.RowSpan="2" Visibility="Visible" VerticalAlignment="Stretch" />
                <ScrollViewer Margin="1" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True"
                              ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
                  <Fluent:MenuPanel x:Name="PART_MenuPanel" IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                </ScrollViewer>
                <Border x:Name="resizeBorder" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="11"
                        BorderBrush="{DynamicResource ContextMenuBarResizeBorderBrush}" BorderThickness="0,1,0,0" Grid.Row="1"
                        CornerRadius="0,0,1,1" Background="{DynamicResource ContextMenuBarResizeBackgoundBrush}">
                  <Grid>
                    <Thumb x:Name="PART_ResizeVerticalThumb" HorizontalAlignment="Stretch" Margin="0,0,0,-90"
                           Width="Auto" Height="10" VerticalAlignment="Top" Cursor="SizeNS"
                           Template="{DynamicResource ResizeVerticalThumbControlTemplate}" />
                    <Thumb x:Name="PART_ResizeBothThumb" HorizontalAlignment="Right" Margin="0,0,0,-90" Width="10"
                           Height="10" VerticalAlignment="Top" Cursor="SizeNWSE" Template="{DynamicResource ResizeBothThumbControlTemplate}" />
                  </Grid>
                </Border>
              </Grid>
            </Grid>
          </Border>
        </Grid>
      </Popup>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="ResizeMode" Value="None">
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Collapsed" />
      </Trigger>
      <Trigger Property="ResizeMode" Value="Both">
        <Setter Property="Visibility" TargetName="PART_ResizeVerticalThumb" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="PART_ResizeBothThumb" Value="Visible" />
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Visible" />
      </Trigger>
      <Trigger Property="ResizeMode" Value="Vertical">
        <Setter Property="Visibility" TargetName="PART_ResizeBothThumb" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="PART_ResizeVerticalThumb" Value="Visible" />
        <Setter Property="Visibility" TargetName="resizeBorder" Value="Visible" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Opacity" TargetName="iconImage" Value="0.25" />
      </Trigger>
      <Trigger Property="Size" Value="Small">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal" />
        <Setter Property="Source" TargetName="iconImage"
                Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="Width" TargetName="iconImage" Value="16" />
        <Setter Property="Height" TargetName="iconImage" Value="16" />
        <Setter Property="Margin" TargetName="iconImage" Value="2" />
        <Setter Property="Margin" TargetName="grid" Value="0" />
      </Trigger>
      <Trigger Property="Size" Value="Middle">
        <Setter Property="Orientation" TargetName="stackPanel" Value="Horizontal" />
        <Setter Property="Source" TargetName="iconImage"
                Value="{Binding Icon, RelativeSource={RelativeSource TemplatedParent}}" />
        <Setter Property="Width" TargetName="stackPanel" Value="Auto" />
        <Setter Property="VerticalAlignment" TargetName="iconImage" Value="Center" />
        <Setter Property="VerticalAlignment" TargetName="PART_ButtonBorder" Value="Stretch" />
        <Setter Property="Width" TargetName="iconImage" Value="16" />
        <Setter Property="Height" TargetName="iconImage" Value="16" />
        <Setter Property="Margin" TargetName="iconImage" Value="2" />
      </Trigger>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonPressedOuterBorderBrush}" />
        <Setter Property="Background" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonPressedOuterBackgroundBrush}" />
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonPressedInnerBorderBrush}" />
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsDropDownOpen" Value="False" />
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}" />
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
        <Setter Property="Background" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonHoverOuterBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonHoverOuterBorderBrush}" />
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible" />
        <Setter Property="Margin" TargetName="rectangle" Value="0" />
        <Setter Property="Margin" TargetName="grid" Value="0" />
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsFocused" Value="True" />
          <Condition Property="IsDropDownOpen" Value="False" />
        </MultiTrigger.Conditions>
        <Setter Property="BorderBrush" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBorderBrush}" />
        <Setter Property="Background" TargetName="border1" Value="{DynamicResource ButtonHoverInnerBackgroundBrush}" />
        <Setter Property="Background" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonHoverOuterBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="PART_ButtonBorder"
                Value="{DynamicResource ButtonHoverOuterBorderBrush}" />
        <Setter Property="Visibility" TargetName="rectangle" Value="Visible" />
      </MultiTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="QuickAccessToolbarStyle" TargetType="{x:Type Fluent:QuickAccessToolBar}">
    <Setter Property="Template" Value="{DynamicResource QuickAccessToolbarControlTemplate}" />
    <Setter Property="FocusManager.IsFocusScope" Value="False" />
  </Style>
  <ControlTemplate x:Key="QuickAccessToolbarControlTemplate" TargetType="{x:Type Fluent:QuickAccessToolBar}">
    <DockPanel x:Name="PART_RootPanel">
      <ContentControl x:Name="menuContentControl" DockPanel.Dock="Right" HorizontalAlignment="Right"
                      Focusable="False">
        <Fluent:DropDownButton CanAddToQuickAccessToolBar="False" x:Name="PART_MenuDownButton" Width="13"
                               HorizontalAlignment="Right" VerticalAlignment="Stretch" Style="{DynamicResource ToolbarDropDownButtonStyle}"
                               Height="22" DockPanel.Dock="Right" IsEnabled="{TemplateBinding IsEnabled}"
                               Icon="pack://application:,,,/Fluent;Component/Themes/Office2010/Images/QuickAccessToolBarDropDown.png" Size="Small"
                               ToolTip="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=QuickAccessToolBarDropDownButtonTooltip, Mode=OneWay}">


          <Fluent:GroupSeparatorMenuItem Style="{DynamicResource MenuGroupSeparatorStyle}"
                                         Header="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=QuickAccessToolBarMenuHeader, Mode=OneWay}" />
          <StackPanel x:Name="PART_MenuPanel" />
          <Separator x:Name="menuSeparator" Style="{DynamicResource MenuSeparatorStyle}" />
          <Fluent:MenuItem x:Name="PART_ShowBelow"
                           Header="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=QuickAccessToolBarMenuShowBelow, Mode=OneWay}" />
          <Fluent:MenuItem x:Name="PART_ShowAbove"
                           Header="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=QuickAccessToolBarMenuShowAbove, Mode=OneWay}"
                           Visibility="Collapsed" />


        </Fluent:DropDownButton>
      </ContentControl>
      <Fluent:DropDownButton x:Name="PART_ToolbarDownButton" HorizontalAlignment="Right" Width="13"
                             Visibility="Collapsed" VerticalAlignment="Stretch" Style="{DynamicResource ToolbarDropDownButtonStyle}" Height="22"
                             DockPanel.Dock="Right" Fluent:KeyTip.Keys="00" Size="Small" IsEnabled="{TemplateBinding IsEnabled}"
                             Icon="pack://application:,,,/Fluent;Component/Themes/Office2010/Images/QuickAccessToolBarExtender.png"
                             ToolTip="{Binding Source={x:Static Fluent:Ribbon.Localization}, Path=QuickAccessToolBarMoreControlsButtonTooltip, Mode=OneWay}">
        <Fluent:DropDownButton.ContextMenu>
          <ContextMenu Style="{DynamicResource EmptyContextMenuStyle}" />
        </Fluent:DropDownButton.ContextMenu>


        <StackPanel Orientation="Horizontal" Background="{DynamicResource QuickAccessToolbarPopupBackgrondBrush}"
                    Width="Auto" Height="26" Margin="-1">
          <StackPanel Orientation="Horizontal" x:Name="PART_ToolBarOverflowPanel" HorizontalAlignment="Left"
                      Width="Auto" Height="Auto" VerticalAlignment="Center" Margin="1,0,0,0" />
          <Label x:Name="popupContentControl" VerticalAlignment="Center" HorizontalAlignment="Left" Width="13"
                 Background="{x:Null}" Height="22" Focusable="False" Padding="0" Margin="1,0" />
        </StackPanel>


      </Fluent:DropDownButton>
      <Rectangle x:Name="rectangle" Fill="Black" Stroke="White" RadiusX="1" RadiusY="1" HorizontalAlignment="Right"
                 Width="3" Height="15" Opacity="0.5" VerticalAlignment="Stretch" DockPanel.Dock="Right" />
      <Rectangle x:Name="rectangle1" Fill="Black" Stroke="White" Width="3" Height="15" RadiusX="1" RadiusY="1"
                 HorizontalAlignment="Left" Opacity="0.5" VerticalAlignment="Stretch" DockPanel.Dock="Left" />
      <StackPanel Orientation="Horizontal" x:Name="PART_ToolBarPanel" Width="Auto" Height="Auto"
                  VerticalAlignment="Stretch" FocusManager.IsFocusScope="False" />
    </DockPanel>
    <ControlTemplate.Triggers>
      <Trigger Property="CanQuickAccessLocationChanging" Value="False">
        <Setter Property="Visibility" TargetName="PART_ShowBelow" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="PART_ShowAbove" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="menuSeparator" Value="Collapsed" />
      </Trigger>
      <Trigger Property="ShowAboveRibbon" Value="False">
        <Setter Property="Visibility" TargetName="PART_ShowBelow" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="PART_ShowAbove" Value="Visible" />
        <Setter Property="Visibility" TargetName="rectangle" Value="Collapsed" />
        <Setter Property="Visibility" TargetName="rectangle1" Value="Collapsed" />
      </Trigger>
      <Trigger Property="HasOverflowItems" Value="True">
        <Setter Property="Visibility" TargetName="PART_ToolbarDownButton" Value="Visible" />
        <Setter Property="Content" TargetName="popupContentControl"
                Value="{Binding ElementName=PART_MenuDownButton, Mode=OneWay}" />
        <Setter Property="Content" TargetName="menuContentControl" Value="{x:Null}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
</ResourceDictionary>